package com.tocean.app.controller.app;

import com.tocean.app.controller.framework.request.RanksSaveRequest;

import com.tocean.app.dto.request.BaseRequest;
import com.tocean.app.dto.response.BaseResponse;
import com.tocean.app.service.framework.RanksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "排名")
@Slf4j
@Validated
@CrossOrigin
@RestController("AppWechatRanksController")
@RequestMapping("/app/wechatRanks")
public class WechatRanksController {

    @Autowired
    private RanksService service;
    /**
     * 功能描述：保存[分数]
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @ApiOperation(value = "保存[分数]")
    @PostMapping("")
    public ResponseEntity<BaseResponse<?>> save(@Valid @RequestBody BaseRequest<RanksSaveRequest> request) {
        service.save(request.getData());
        return ResponseEntity.ok(BaseResponse.ok());
    }

    /**
     * 功能描述：获取排行榜
     *
     * @return
     */
    @CrossOrigin
    @ApiOperation(value = "获取排行榜")
    @GetMapping("/list")
    public ResponseEntity<BaseResponse<?>> ranksList() {
        return ResponseEntity.ok(BaseResponse.ok(service.ranksList()));
    }






}
